package chips440.tiles;

import chips440.internals.Player;
import chips440.main.Types;

/**
 * Door tile - blocks the player's movement unless (s)he has the correct color
 * key. images for this tile are called "door<door color>.gif".
 *
 * @author Ryan Hofler
 * @version 0.1
 */
public class DoorTile extends Tile{
    private Types.Item key;

    /**
     * Make a new DoorTile, colored as indicated by the parameter. 
     *
     * @param k the Types.Item that unlocks this door (usually *_KEY)
     */
    public DoorTile(Types.Item k){
        this.key = k;
	this.image = "door_" + this.key;
    }

    public synchronized Types.TileAct okToStep(Player player){
	if(player.hasItem(this.key)){
	    player.takeItem(this.key);
	    return Types.TileAct.OPEN;
	}
        return Types.TileAct.STOP;
    }
}
